<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .outer{
      width: 300px;
      height: 300px;
      background-color: red;
      margin: 0 auto;
      padding: 50px;
      box-sizing: border-box;
    }
    .center{
      width: 200px;
      height: 200px;
      background-color: pink;
      padding: 50px;
      box-sizing: border-box;
    }
    .inner{
      width: 100px;
      height: 100px;
      /* 设置背景渐变色 线性渐变 to right/bottom to right bottom 径向渐变 */
      background-image:linear-gradient(to right bottom,red,pink,blue);
    }
  </style>
</head>
<body>
  <div class="outer">
    <div class="center">
      <div class="inner"></div>
    </div>
  </div>
  <script>
    // 事件冒泡：事件从内向外触发 从最具体的元素（最深的元素）开始触发
    var outer = document.querySelector('.outer');
    var center = document.querySelector('.center');
    var inner = document.querySelector('.inner');
    outer.onclick = function(event){
      console.log('outer被点击了');
    }
    center.onclick = function(event){
      console.log('center被点击了');
    }
    inner.onclick = function(event){
      console.log('inner被点击了');
      // 阻止事件冒泡
      event.stopPropagation()
    }
  </script>
</body>
</html>